package com.hans.scala.ImplicitConversion

/**
 * 隐式方法与隐式参数
 * Created by Juntao.Zhang on 2014/4/28.
 */
object SimpleDemo extends App {
  def maxProxy(x: Int, y: Int)(implicit max: (Int, Int) => Int) = {
    println("before max")
    val t = max(x, y)
    println("after max")
    t
  }

  implicit def max(x: Int, y: Int): Int = {
    println("in the max function")
    if (x > y) x; else y
  }

  println("result:" + maxProxy(4, 5))
}

object SimpleDemo2 extends App {
  implicit class CiscoInt(x: Int) {
    def addOne(): Int = {
      x + 1
    }
  }

  println(1.addOne())
}
